package cn.edu.zafu.bigdata.bd121.student.cli;

import cn.edu.zafu.bigdata.bd121.student.command.BaseCommand;
import cn.edu.zafu.bigdata.bd121.student.command.impl.*;

/**
 * 菜单类
 *
 * @author 202211090121
 */
public class Menu {

    /**
     * 展示菜单
     */
    public static void showMenu() {
        System.out.println("======= 学生信息管理系统 =======");
        System.out.println("1. 添加学生信息");
        System.out.println("2. 检索学生信息");
        System.out.println("3. 更新学生信息");
        System.out.println("4. 删除学生信息");
        System.out.println("5. 退出程序");
        System.out.print("请输入操作编号(1-5): ");
    }

    /**
     * 选择菜单
     *
     * @param choice 选择编号
     * @return 选择的操作
     */
    public static BaseCommand selectMenu(String choice) {
        return switch (choice) {
            case "1" -> new InsertStudent();
            case "2" -> new SelectStudent();
            case "3" -> new UpdateStudent();
            case "4" -> new DeleteStudent();
            case "5" -> new QuitSystem();
            default -> new WrongInputHandler();
        };
    }

    /**
     * 禁止实例化
     */
    private Menu() {
    }
}
